package com.familyaccount.model;

import lombok.Data;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
public class Category {
    private int id;
    private String name;
    private CategoryType type;
    private String description;
    private LocalDateTime createdAt;
    private String createdAtStr;

    public enum CategoryType {
        INCOME,
        EXPENSE
    }

    public Category() {
    }

    public Category(String name, CategoryType type, String description) {
        this.name = name;
        this.type = type;
        this.description = description;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
        if (createdAt != null) {
            this.createdAtStr = createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
        } else {
            this.createdAtStr = null;
        }
    }
} 